﻿/// <reference path="http://localhost:8021/js/jquery-1.7.2.min.js" />

$(function () {

    var business_link = $('.business_link');
    var main_left = $('.main_left');

    //导航
    $("li[name='navigation']").live("mouseover", function () {
        $(this).children().eq(1).show();
    }).live("mouseout", function () {
        $(this).children().eq(1).hide();
    });

    //左侧菜单	
    $("a[name='hasLevel4']").live("click", function () {
        if ($(this).next().is(":hidden")) {
            $(this).addClass("selected")
            $(this).parent().addClass("bordertop")
            $(this).next().slideDown(function () {
                //展开菜单后重新定义移动菜单的位置
                setPosition();
            });
        }
        else {
            $(this).removeClass("selected")
            $(this).parent().removeClass("bordertop")
            $(this).next().slideUp(function () {
                setPosition();
            });
        }
    });
    //联想控股成员企业三级菜单
    $('.member').hover(function () {
        $(this).children('ul').show();
    }, function () {
        $(this).children('ul').hide();
    });
    $('.member ul>li').hover(function () {
        var index = $(this).prevAll().length;
        $(this).children('ul').css('top', index * $(this).height()).show();
    }, function () {
        $(this).children('ul').hide();
    }).find('ul').hide();

    //鼠标滚动事件
    var margin_top = 40;
    $(window).scroll(function () {
        setPosition();
    });
    $(window).resize(function () {
        setPosition();
    });

    //加载页面时初始化位置 
    setPosition();

    //设置位置
    function setPosition() {
        if (business_link.length > 0) {
            business_link.css('top', main_left.offset().top + main_left.height() + margin_top).css('left', main_left.offset().left);
            if ($(document).scrollTop() > main_left.offset().top + main_left.height()) {
                business_link.css('top', $(document).scrollTop() + margin_top);
            }
            else {
                business_link.css('top', main_left.offset().top + main_left.height() + margin_top);
            }
        }

    }

});

///获取Url中的参数值
function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return r[2];
    }
    else {
        return "";
    }
}
